# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Antoine POPINEAU <antoine at popineau dot eu>

pkgname=greetd-tuigreet
_pkgname=${pkgname#*-}
pkgver=0.8.0
pkgrel=2
pkgdesc='A console UI greeter for greetd'
url="https://github.com/apognu/$_pkgname"
license=(GPL3)
arch=(loong64 x86_64)
depends=(gcc-libs
         greetd
         systemd)
provides=(greetd-greeter)
makedepends=(cargo
             scdoc)
_archive="$_pkgname-$pkgver"
source=("$url/archive/$pkgver/$_archive.tar.gz"
        "$_pkgname.tmpfiles")
sha256sums=('ed371ebe288a3e5782f01681c6c4ed4786b470184af286fa0e7b8898e47c154e'
            '8f83aee7874aab5d06981a1d1cd05df906368a79dbca90d157a33a2f023b67d3')

prepare() {
	cd "$_archive"
	cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
	cd "$_archive"
	cargo build --frozen --release --all-features
	scdoc < contrib/man/$_pkgname-1.scd > contrib/man/$_pkgname.1
}

check() {
	cd "$_archive"
	cargo test --frozen --all-features
}

package() {
	cd "$_archive"
	install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$_pkgname"
	install -Dm0755 -t "$pkgdir/usr/share/man/man1/" "contrib/man/$_pkgname.1"
	install -Dm0644 "../$_pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$_pkgname.conf"
}
